﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SchedulerControl.Controls
{

        [TemplatePart(Name="DayIconGrid", Type=typeof(Grid))]
        public class ChangeScheduleViewControl : CheckBox
        {
            private Grid _dayIconGrid;
            private Grid _workingWeekIconGrid;
            private Grid _weekIconGrid;
            private Grid _monthIconGrid;

           private TextBlock _textElement;

            private ViewLayoutTypes _layoutType = ViewLayoutTypes.Day;
            public ViewLayoutTypes LayoutType
            {
                get { return _layoutType; }
                set { _layoutType = value; }
            }

            public string _text;
            public string Text
            {
                get
                {
                    return _text;
                }
                set
                {
                    _text = value;
                }
            }

            public ChangeScheduleViewControl()
            {
                this.DefaultStyleKey = typeof(ChangeScheduleViewControl);
            }

            public override void OnApplyTemplate()
            {
                base.OnApplyTemplate();
                _dayIconGrid = GetTemplateChild("DayIconGrid") as Grid;
                _workingWeekIconGrid = GetTemplateChild("WorkWeekIconGrid") as Grid;
                _weekIconGrid = GetTemplateChild("WeekIconGrid") as Grid;
                _monthIconGrid = GetTemplateChild("MonthIconGrid") as Grid;
                _textElement = GetTemplateChild("textBlock") as TextBlock;
                _dayIconGrid.Visibility = System.Windows.Visibility.Collapsed;
                _workingWeekIconGrid.Visibility = System.Windows.Visibility.Collapsed;
                _weekIconGrid.Visibility = System.Windows.Visibility.Collapsed;
                _monthIconGrid.Visibility = System.Windows.Visibility.Collapsed;
               
                switch(LayoutType)
                {
                    case ViewLayoutTypes.Day :
                        _dayIconGrid.Visibility = System.Windows.Visibility.Visible;  
                        break;
                    case ViewLayoutTypes.WorkWeek:
                        _workingWeekIconGrid.Visibility = System.Windows.Visibility.Visible;
                        break;
                    case ViewLayoutTypes.Week:
                        _weekIconGrid.Visibility = System.Windows.Visibility.Visible;
                        break;
                    case ViewLayoutTypes.Month:
                        _monthIconGrid.Visibility = System.Windows.Visibility.Visible;
                        break;
                }
                _textElement.Text = _text;

            }


        }
    
}
